﻿using Microsoft.VisualStudio.TestTools.UnitTesting;
using élénkPróbája.native;
using élénkPróbája.Test.extention;

namespace élénkPróbája.Test
{
    [TestClass]
    public class CacheFactoryTester
    {
        CacheFactory cache;

        public CacheFactoryTester()
        {
            cache = new CacheFactory();
        }

        [TestMethod]
        public void GetInstance_WhenNotCached_CreatesInstance()
        {
            var result = cache.GetOrCreateInstance(typeof(TestModel));

            result.ShouldBe<TestModel>();
            result.ShouldNotBeNull();
        }

        [TestMethod]
        public void GetInstance_WhenCached_ReUsesInstance()
        {
            var instance = cache.GetOrCreateInstance(typeof(TestModel));

            var result = cache.GetOrCreateInstance(typeof(TestModel));
            result.ShouldBeTheSameAs(instance);
        }

        private class TestModel
        {

        }
    }
}
